﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LibNiconico.NiconicoApi;
using LibNiconico.NiconicoApi.Lives;
using LibNiconico.NiconicoApi.HeartBeat;

namespace LibNiconico.NiconicoApi.Lives.Comments
{
    
    /// <summary>
    /// ニコ生スレッドコメントハンドラ
    /// </summary>
    /// <param name="args"></param>
    public delegate void NicoLiveThreadCommentHandler(NicoLiveCommentClientThreadCommentEventArgs args);

    /// <summary>
    /// ニコ生チャット送信結果コメントハンドラ
    /// </summary>
    /// <param name="args"></param>
    public delegate void NicoLiveChatResultCommentHandler(NicoLiveCommentClientChatResultCommentEventArgs args);

    /// <summary>
    /// ニコ生チャットコメントハンドラ
    /// </summary>
    /// <param name="args"></param>
    public delegate void NicoLiveChatCommentHandler(NicoLiveCommentClientChatCommentEventArgs args);

    /// <summary>
    /// ニコ生接続切断ハンドラ
    /// </summary>
    /// <param name="args"></param>
    public delegate void NicoLiveCloseHandler(NicoLiveCommentClientCloseEventArgs args);



    /// <summary>
    /// ニコ生読取例外ハンドラ
    /// </summary>
    /// <param name="args"></param>
    public delegate void NicoLiveReadExceptionHandler(NicoLiveReadExceptionEventArgs args);



    /// <summary>
    /// ニコ生コメントクライアント関連イベント引数ベースクラス
    /// </summary>
    public abstract class NicoLiveCommentClientEventArgsBase : EventArgs
    {
        internal NicoLiveCommentClientEventArgsBase(INicoLiveCommentClient client) 
        {
            Client = client;
        }

        /// <summary>
        /// このイベント呼び出し元のコメントクライアント
        /// </summary>
        public INicoLiveCommentClient Client { get; private set; }

    }

    /// <summary>
    /// ニコ生スレッドコメント受信イベント引数
    /// </summary>
    public sealed class NicoLiveCommentClientThreadCommentEventArgs : NicoLiveCommentClientEventArgsBase
    {
        internal NicoLiveCommentClientThreadCommentEventArgs(INicoLiveCommentClient client, NicoLiveThreadComment threadComment)
            : base(client) 
        {
            ThreadComment = threadComment;
        }

        /// <summary>
        /// スレッドコメント
        /// </summary>
        public NicoLiveThreadComment ThreadComment { get; private set; }

    }

    /// <summary>
    /// ニコ生コメント送信結果受信イベント引数
    /// </summary>
    public sealed class NicoLiveCommentClientChatResultCommentEventArgs : NicoLiveCommentClientEventArgsBase
    {
        internal NicoLiveCommentClientChatResultCommentEventArgs(INicoLiveCommentClient client, NicoLiveChatResultComment chatResult)
            : base(client)
        {
            ChatResult = chatResult;
        }
        
        /// <summary>
        /// 送信結果
        /// </summary>
        public NicoLiveChatResultComment ChatResult { get; private set; }
    }

    /// <summary>
    /// ニコ生チャットコメント受信イベント引数
    /// </summary>
    public sealed class NicoLiveCommentClientChatCommentEventArgs : NicoLiveCommentClientEventArgsBase
    {
        internal NicoLiveCommentClientChatCommentEventArgs(INicoLiveCommentClient client, ICollection<NicoLiveChatComment> chatComments)
            : base(client) 
        {
            ChatComments = chatComments;
        }

        /// <summary>
        /// チャットコメント
        /// </summary>
        public ICollection<NicoLiveChatComment> ChatComments { get; private set; }
    }

    /// <summary>
    /// ニコ生コメントクライアント接続切断イベント引数
    /// </summary>
    public sealed class NicoLiveCommentClientCloseEventArgs : NicoLiveCommentClientEventArgsBase
    {
        internal NicoLiveCommentClientCloseEventArgs(INicoLiveCommentClient client, Exception e, string reason)
            : base(client) 
        {
            Exception = e;
            Reason = reason;
        }

        /// <summary>
        /// 切断の原因となった例外
        /// </summary>
        public Exception Exception { get; private set; }

        /// <summary>
        /// 切断した理由
        /// </summary>
        public string Reason { get; private set; }
    }

    /// <summary>
    /// ニコ生コメント読み取り例外発生イベント引数
    /// </summary>
    public sealed class NicoLiveReadExceptionEventArgs : NicoLiveCommentClientEventArgsBase
    {
        internal NicoLiveReadExceptionEventArgs(INicoLiveCommentClient client, Exception e)
            : base(client)
        {
            Exception = e;
        }

        /// <summary>
        /// 発生した例外
        /// </summary>
        public Exception Exception { get; internal set; }
    }



    
}
